﻿namespace FFF.Test.Application.Framework.Providers
{
    using Abp.Authorization;
    using Abp.Localization;
    using Abp.MultiTenancy;
    using FFF.Test.Entity;
    using FFF.Test.Util.Consts;

    /// <summary>
    /// abp权限验证
    /// </summary>
    public class YdmAbpAuthorizationProvider : AuthorizationProvider
    {
        /// <summary>
        /// 设置用户角色
        /// </summary>
        /// <param name="context">权限上下文</param>
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            context.CreatePermission(PermissionNames.PagesUsers, L("Users"));
            context.CreatePermission(PermissionNames.PagesRoles, L("Roles"));
            context.CreatePermission(PermissionNames.PagesTenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
        }

        /// <summary>
        /// 多语言设置
        /// </summary>
        /// <param name="name">对应多语言的name</param>
        /// <returns>多语言</returns>
        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, AppConfigConsts.LocalizationSourceName);
        }
    }
}
